import { createRouter, createWebHashHistory } from "vue-router";
import Announcement from "~/components/Announcement.vue";
import Books from "~/components/Books.vue";
import ChangePassword from "~/components/ChangePassword.vue";
import Forum from "~/components/Forum.vue";
import UserInfo from "~/components/UserInfo.vue";
import UserManagement from "~/components/UserManagement.vue";
import NotFound from "~/pages/Gsearch.vue";
import Index from "~/pages/Index.vue";
import Login from "~/pages/login.vue";
import Welcome from "~/pages/welcome.vue";
import GradeSearch from "~/components/GradeSearch.vue"; // 🔥 新增导入

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/home",
      component: Index,
      children: [
        {
          path: "infocontrol/userinfo",
          component: UserInfo,
          meta: { title: "用户信息" },
        },
        {
          path: "infocontrol/changepwd",
          component: ChangePassword,
          meta: { title: "修改密码" },
        },
        {
          path: "infocontrol/usermanagement",
          component: UserManagement,
          meta: { title: "管理用户" },
        },
        {
          path: "books/control",
          component: Books,
          meta: { title: "图书管理" },
        },
        // 🔥 新增成绩查询路由
        {
          path: "gradesearch",
          component: GradeSearch,
          meta: { title: "成绩查询" },
        },
        {
          path: "user/forum",
          component: Forum,
          meta: { title: "论坛" },
        },
        {
          path: "user/announcement",
          component: Announcement,
          meta: { title: "公告发布" },
        },
      ],
    },
    {
      path: "/",
      component: Welcome,
    },
    {
      path: "/login/:type",
      component: Login,
    },
    {
      path: "/:pathMatch(.*)*",
      component: NotFound,
    },
  ],
});

export default router;